package register.view;

/*
 * register.java
 *
 * Created on 2009年2月13日, 下午1:55
 */

//import javax.swing.ImageIcon;
import register.model.*;
import java.util.Date;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import register.ucm.GeneralSwitch;
import register.ucm.GenerateID;
import register.ucm.PhotoCamera;
import register.ucm.RegisterMysqlInsert;
import javax.swing.JOptionPane;
import main.view.MainTable;
import medium.MsgSender;

//import register.ucm.GetPathFromPhoto;
/**
 *
 * @author  Donghui
 */

public class RegisterPanel extends javax.swing.JFrame {
    private static RegisterPanel local;
    private ButtonModel button;
    private InputValueModel value;
    private GeneralSwitch switcher;
    private String regDate;
    private String expDate;
    private Date today;
    private GenerateID editor;
    private PhotoCamera camera;
    private String id;
    private RegisterMysqlInsert insert;

    private MsgSender sender;

    /** Creates new form register */
    public RegisterPanel() {
        initComponents();
        pathlabel.setVisible(false);
        register.setEnabled(false);
        snap.setEnabled(false);
        generate.setEnabled(false);
        button=new ButtonModel();
        value=new InputValueModel();
        local=this;

        this.getRegDate();
        this.getExpDate();
        this.showDate();

        this.degree.setEnabled(false);
        this.dormitory.setEnabled(false);
        this.mcourse.setEnabled(false);
        this.title.setEnabled(false);
        this.college.setEnabled(false);
        this.department.setEnabled(false);
    }

    public void getRegDate()
    {
        today=new Date();
        SimpleDateFormat kiper=new SimpleDateFormat("yyyy-MM-dd");
        String tep=kiper.format(today);
        value.setRegDate(tep);
        regDate=tep;
    }

    public void getExpDate()
    {
        try
        {
        Calendar startDate=Calendar.getInstance();
        today=new SimpleDateFormat("yyyy-MM-dd").parse(regDate);
        startDate.setTime(today);
        startDate.add(Calendar.YEAR, 1); //Offset 1 year
        Date endDate=startDate.getTime();
        SimpleDateFormat clar=new SimpleDateFormat("yyyy-MM-dd");
        String dateTemp=clar.format(endDate);

        value.setExpDate(dateTemp);
        expDate=dateTemp;
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    public void showDate()
    {
        this.edate.setText(expDate);
        this.rdate.setText(regDate);
    }

    public static RegisterPanel getInstance()
    {
        if(local==null)
        {
            local=new RegisterPanel();
            local.setVisible(true);
        }
        return local;
    }

    public ButtonModel getButtonModel()
    {
        button.setRegister(register);
        button.setCancel(cancel);
        button.setGenerate(generate);
        button.setCollege(college);
        button.setDegree(degree);
        button.setDepartment(department);
        button.setDormitory(dormitory);
        button.setExpDate(edate);
        button.setMajorCourse(mcourse);
        button.setRegDate(rdate);
        button.setTitle(title);
        button.setTBook(tbook);
        button.setStBook(stbook);
        button.setStCourse(stcourse);
        button.setStfAO(stfao);
        button.setStfBook(stfbook);
        button.setStfCA(stfca);
        button.setStfLib(stflib);
        button.setStfPIO(stfpio);
        button.setStfSAA(stfsaa);
        button.setStfSAO(stfsao);
        button.setRID(rid);
        button.setCID(cid);
        button.setPassword(psword);
        button.setConfirmPassword(cpsword);
        button.setPhoto(photo);
        button.setPath(pathlabel);
        button.setSnap(snap);
        return button;
    }

    public InputValueModel getInputValueModel()
    {
        value.setName(name.getText());
        value.setAddress(address.getText());
        value.setCardId(cid.getText());
        value.setCollege(college.getSelectedItem().toString());
        value.setConfirmPassWord(String.valueOf(cpsword.getPassword()));
        value.setDegree(degree.getSelectedItem().toString());
        value.setDepartment(department.getSelectedItem().toString());
        value.setDormitory(dormitory.getText());
        value.setGender(gender.getSelectedItem().toString());
        value.setGroup(group.getSelectedItem().toString());
        value.setMajorCourse(mcourse.getSelectedItem().toString());
        value.setPassWord(String.valueOf(psword.getPassword()));
        value.setPhone(phone.getText());
        value.setTitle(title.getSelectedItem().toString());
        value.setTBook(tbook.isSelected());
        value.setStBook(stbook.isSelected());
        value.setStCourse(stcourse.isSelected());
        value.setStfAO(stfao.isSelected());
        value.setStfBook(stfbook.isSelected());
        value.setStfCA(stfca.isSelected());
        value.setStfLib(stflib.isSelected());
        value.setStfPIO(stfpio.isSelected());
        value.setStfSAA(stfsaa.isSelected());

        return value;
    }



    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        perinfo = new javax.swing.JPanel();
        photo = new javax.swing.JLabel();
        name = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        address = new javax.swing.JTextField();
        phone = new javax.swing.JTextField();
        group = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        rdate = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        edate = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        dormitory = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        college = new javax.swing.JComboBox();
        jLabel11 = new javax.swing.JLabel();
        degree = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        gender = new javax.swing.JComboBox();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        title = new javax.swing.JComboBox();
        jLabel15 = new javax.swing.JLabel();
        department = new javax.swing.JComboBox();
        jLabel22 = new javax.swing.JLabel();
        mcourse = new javax.swing.JComboBox();
        jLabel23 = new javax.swing.JLabel();
        snap = new javax.swing.JButton();
        pathlabel = new javax.swing.JLabel();
        priinfo = new javax.swing.JPanel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        cid = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        psword = new javax.swing.JPasswordField();
        jLabel20 = new javax.swing.JLabel();
        cpsword = new javax.swing.JPasswordField();
        jLabel21 = new javax.swing.JLabel();
        rid = new javax.swing.JTextField();
        generate = new javax.swing.JButton();
        prialoc = new javax.swing.JPanel();
        jLabel24 = new javax.swing.JLabel();
        stbook = new javax.swing.JCheckBox();
        stcourse = new javax.swing.JCheckBox();
        jLabel25 = new javax.swing.JLabel();
        tbook = new javax.swing.JCheckBox();
        jLabel26 = new javax.swing.JLabel();
        stfbook = new javax.swing.JCheckBox();
        stfao = new javax.swing.JCheckBox();
        stfpio = new javax.swing.JCheckBox();
        stflib = new javax.swing.JCheckBox();
        stfsao = new javax.swing.JCheckBox();
        stfsaa = new javax.swing.JCheckBox();
        stfca = new javax.swing.JCheckBox();
        register = new javax.swing.JButton();
        cancel = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Register Procedure");
        setResizable(false);

        jTabbedPane1.setFont(new java.awt.Font("Arial", 0, 12));
        jTabbedPane1.setMinimumSize(new java.awt.Dimension(136, 60));

        jScrollPane1.setPreferredSize(new java.awt.Dimension(850, 750));

        perinfo.setPreferredSize(new java.awt.Dimension(700, 500));

        photo.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        photo.setPreferredSize(new java.awt.Dimension(180, 240));
        photo.setVerifyInputWhenFocusTarget(false);

        name.setFont(new java.awt.Font("Arial", 0, 12));
        name.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nameActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Arial", 0, 12));
        jLabel2.setText("Name ");

        jLabel3.setFont(new java.awt.Font("Arial", 0, 12));
        jLabel3.setText("Gender");

        jLabel4.setFont(new java.awt.Font("Arial", 0, 12));
        jLabel4.setText("Address");

        jLabel5.setFont(new java.awt.Font("Arial", 0, 12));
        jLabel5.setText("Phone Number");

        jLabel6.setFont(new java.awt.Font("Arial", 0, 12));
        jLabel6.setText("Group");

        address.setFont(new java.awt.Font("Arial", 0, 12));
        address.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addressActionPerformed(evt);
            }
        });

        phone.setFont(new java.awt.Font("Arial", 0, 12));
        phone.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                phoneActionPerformed(evt);
            }
        });

        group.setFont(new java.awt.Font("Arial", 0, 12));
        group.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "- click to select -", "Student", "Teacher", "Staff" }));
        group.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                groupActionPerformed(evt);
            }
        });

        jLabel7.setFont(new java.awt.Font("Arial", 0, 12));
        jLabel7.setText("Register Date");

        rdate.setEditable(false);
        rdate.setFont(new java.awt.Font("Arial", 0, 12));
        rdate.setText("student,teacher,staff");

        jLabel8.setFont(new java.awt.Font("Arial", 0, 12));
        jLabel8.setText("Expiring Date");

        edate.setEditable(false);
        edate.setFont(new java.awt.Font("Arial", 0, 12));
        edate.setText("student");
        edate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                edateActionPerformed(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("Arial", 0, 12));
        jLabel9.setText("Dormitory");

        dormitory.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dormitoryActionPerformed(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Arial", 0, 12));
        jLabel10.setText("College");

        college.setFont(new java.awt.Font("Arial", 0, 12));
        college.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "- click to select -", "Computing & Technology", "Economy & Management", "Foreign Language", "Mathematics" }));

        jLabel11.setFont(new java.awt.Font("Arial", 0, 12));
        jLabel11.setText("Degree");

        degree.setFont(new java.awt.Font("Arial", 0, 12));
        degree.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "- click to select -", "Bachelor", "Master", "Doctor" }));

        jLabel12.setFont(new java.awt.Font("Arial", 0, 12));
        jLabel12.setText("_________________________ Detailed Information _________________________");

        gender.setFont(new java.awt.Font("Arial", 0, 12));
        gender.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "- click to select -", "Male", "Female" }));

        jLabel13.setFont(new java.awt.Font("Arial", 0, 12));
        jLabel13.setText("__________________________ Base Information ___________________________");

        jLabel14.setFont(new java.awt.Font("Arial", 0, 12));
        jLabel14.setText("Title");

        title.setFont(new java.awt.Font("Arial", 0, 12));
        title.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "- click to select -", "Assistant", "Lecturer", "Associate Professor", "professor" }));

        jLabel15.setFont(new java.awt.Font("Arial", 0, 12));
        jLabel15.setText("Department");

        department.setFont(new java.awt.Font("Arial", 0, 12));
        department.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "- click to select -", "Department of Finanical Affairs", "Educational Administration Center", "Library" }));

        jLabel22.setFont(new java.awt.Font("Arial", 0, 12));
        jLabel22.setText("Major Course");

        mcourse.setFont(new java.awt.Font("Arial", 0, 12));
        mcourse.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "- click to select -", "BC2045" }));

        snap.setFont(new java.awt.Font("Arial", 0, 12));
        snap.setText("Capture Photo");
        snap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                snapActionPerformed(evt);
            }
        });

        pathlabel.setText("jLabel1");

        javax.swing.GroupLayout perinfoLayout = new javax.swing.GroupLayout(perinfo);
        perinfo.setLayout(perinfoLayout);
        perinfoLayout.setHorizontalGroup(
            perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(perinfoLayout.createSequentialGroup()
                .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(perinfoLayout.createSequentialGroup()
                        .addGap(428, 428, 428)
                        .addComponent(jLabel23))
                    .addGroup(perinfoLayout.createSequentialGroup()
                        .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(perinfoLayout.createSequentialGroup()
                                .addGap(46, 46, 46)
                                .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(pathlabel, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(photo, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(perinfoLayout.createSequentialGroup()
                                .addGap(75, 75, 75)
                                .addComponent(snap, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(49, 49, 49)
                        .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, perinfoLayout.createSequentialGroup()
                                    .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(perinfoLayout.createSequentialGroup()
                                            .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(perinfoLayout.createSequentialGroup()
                                                    .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(rdate, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)
                                                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(college, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                        .addComponent(title, 0, 211, Short.MAX_VALUE)
                                                        .addComponent(department, 0, 211, Short.MAX_VALUE))
                                                    .addGap(6, 6, 6))
                                                .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGap(6, 6, 6))
                                        .addGroup(perinfoLayout.createSequentialGroup()
                                            .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                                    .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(mcourse, 0, 205, Short.MAX_VALUE)
                                        .addComponent(jLabel22)
                                        .addComponent(jLabel8)
                                        .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(degree, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(dormitory, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)
                                        .addComponent(edate, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE))))
                            .addComponent(group, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(gender, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(phone, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(address, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(name, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 444, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel13))))
                .addContainerGap())
        );
        perinfoLayout.setVerticalGroup(
            perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(perinfoLayout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(photo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, perinfoLayout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addGap(20, 20, 20)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(gender, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(address, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(phone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(group, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(perinfoLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jLabel12)
                        .addGap(18, 18, 18)
                        .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(jLabel8))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(rdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(edate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(jLabel9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(college, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(dormitory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(jLabel14))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(degree, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(title, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel22)
                            .addComponent(jLabel15))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(perinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(mcourse, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(department, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, perinfoLayout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addComponent(snap)
                        .addGap(169, 169, 169)
                        .addComponent(pathlabel)
                        .addGap(371, 371, 371)))
                .addComponent(jLabel23))
        );

        jScrollPane1.setViewportView(perinfo);

        jTabbedPane1.addTab("Personal Information", jScrollPane1);

        jLabel16.setText("________________________ RFID Card _________________________");

        jLabel17.setText("Card Number");

        cid.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cidActionPerformed(evt);
            }
        });

        jLabel18.setText("_______________________ Private Code _______________________");

        jLabel19.setText("New Password");

        jLabel20.setText("Confirm Password");

        jLabel21.setText("___________________________ ID _____________________________");

        generate.setText("Generate ID");
        generate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                generateActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout priinfoLayout = new javax.swing.GroupLayout(priinfo);
        priinfo.setLayout(priinfoLayout);
        priinfoLayout.setHorizontalGroup(
            priinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(priinfoLayout.createSequentialGroup()
                .addGap(184, 184, 184)
                .addGroup(priinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel20)
                    .addComponent(jLabel19)
                    .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel21, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(priinfoLayout.createSequentialGroup()
                        .addComponent(rid, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(generate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jLabel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cid)
                    .addComponent(psword)
                    .addComponent(cpsword))
                .addContainerGap(252, Short.MAX_VALUE))
        );
        priinfoLayout.setVerticalGroup(
            priinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(priinfoLayout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addComponent(jLabel21)
                .addGap(18, 18, 18)
                .addGroup(priinfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(generate))
                .addGap(54, 54, 54)
                .addComponent(jLabel16)
                .addGap(18, 18, 18)
                .addComponent(jLabel17)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(53, 53, 53)
                .addComponent(jLabel18)
                .addGap(18, 18, 18)
                .addComponent(jLabel19)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(psword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel20)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cpsword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(220, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Private Information", priinfo);

        jLabel24.setText("________________________________________ Student ___________________________________________");

        stbook.setText("Borrowing Books");
        stbook.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stbookActionPerformed(evt);
            }
        });

        stcourse.setText("Choosing Courses");
        stcourse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stcourseActionPerformed(evt);
            }
        });

        jLabel25.setText("________________________________________ Teacher ___________________________________________");

        tbook.setText("Borrowing Books");
        tbook.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbookActionPerformed(evt);
            }
        });

        jLabel26.setText("_________________________________________ Staff ____________________________________________");

        stfbook.setText("Borrowing Books");
        stfbook.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stfbookActionPerformed(evt);
            }
        });

        stfao.setText("Account Operator");

        stfpio.setText("Personal Information Operator");
        stfpio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stfpioActionPerformed(evt);
            }
        });

        stflib.setText("Library Operator");
        stflib.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stflibActionPerformed(evt);
            }
        });

        stfsao.setText("Student's Achievement Operator");
        stfsao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stfsaoActionPerformed(evt);
            }
        });

        stfsaa.setText("Student Association Administrator");

        stfca.setText("Course Administrator");

        javax.swing.GroupLayout prialocLayout = new javax.swing.GroupLayout(prialoc);
        prialoc.setLayout(prialocLayout);
        prialocLayout.setHorizontalGroup(
            prialocLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(prialocLayout.createSequentialGroup()
                .addGap(86, 86, 86)
                .addGroup(prialocLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(prialocLayout.createSequentialGroup()
                        .addComponent(tbook)
                        .addContainerGap())
                    .addGroup(prialocLayout.createSequentialGroup()
                        .addComponent(jLabel26)
                        .addContainerGap())
                    .addGroup(prialocLayout.createSequentialGroup()
                        .addGroup(prialocLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(prialocLayout.createSequentialGroup()
                                .addComponent(stfca)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 407, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(prialocLayout.createSequentialGroup()
                                .addGroup(prialocLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(stfsao)
                                    .addComponent(stfpio)
                                    .addComponent(stfbook))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 122, Short.MAX_VALUE)
                                .addGroup(prialocLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(stfsaa, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(stfao)
                                    .addComponent(stflib))
                                .addGap(158, 158, 158)))
                        .addContainerGap())
                    .addGroup(prialocLayout.createSequentialGroup()
                        .addComponent(stbook)
                        .addGap(211, 211, 211)
                        .addComponent(stcourse)
                        .addContainerGap())
                    .addGroup(prialocLayout.createSequentialGroup()
                        .addComponent(jLabel24, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(158, 158, 158))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, prialocLayout.createSequentialGroup()
                        .addComponent(jLabel25, javax.swing.GroupLayout.DEFAULT_SIZE, 700, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        prialocLayout.setVerticalGroup(
            prialocLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(prialocLayout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(jLabel24)
                .addGap(18, 18, 18)
                .addGroup(prialocLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(stbook)
                    .addComponent(stcourse))
                .addGap(58, 58, 58)
                .addComponent(jLabel25)
                .addGap(18, 18, 18)
                .addComponent(tbook)
                .addGap(49, 49, 49)
                .addComponent(jLabel26)
                .addGap(18, 18, 18)
                .addGroup(prialocLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(prialocLayout.createSequentialGroup()
                        .addGroup(prialocLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(stfbook)
                            .addComponent(stflib))
                        .addGap(18, 18, 18)
                        .addComponent(stfpio)
                        .addGap(18, 18, 18)
                        .addComponent(stfsao))
                    .addGroup(prialocLayout.createSequentialGroup()
                        .addGap(41, 41, 41)
                        .addComponent(stfao)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(stfsaa)))
                .addGap(18, 18, 18)
                .addComponent(stfca)
                .addContainerGap(194, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Privilege Allocation", prialoc);

        register.setFont(new java.awt.Font("Arial", 0, 12));
        register.setText("Register");
        register.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                registerActionPerformed(evt);
            }
        });

        cancel.setFont(new java.awt.Font("Arial", 0, 12));
        cancel.setText("Cancel");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 801, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(317, 317, 317)
                        .addComponent(register)
                        .addGap(18, 18, 18)
                        .addComponent(cancel, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 648, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(register)
                    .addComponent(cancel))
                .addContainerGap())
        );

        jTabbedPane1.getAccessibleContext().setAccessibleName("Base Information");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cidActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cidActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_cidActionPerformed

    private void stbookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stbookActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_stbookActionPerformed

    private void stcourseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stcourseActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_stcourseActionPerformed

    private void tbookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbookActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_tbookActionPerformed

    private void stfbookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stfbookActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_stfbookActionPerformed

    private void stfpioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stfpioActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_stfpioActionPerformed

    private void stflibActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stflibActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_stflibActionPerformed

    private void stfsaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stfsaoActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_stfsaoActionPerformed

    private void registerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_registerActionPerformed

        insert=new RegisterMysqlInsert();
        boolean tp=insert.insertValue();
        if(tp)
        {
            JOptionPane.showMessageDialog(null,"Committing successfully");
            this.setVisible(false);
            MainTable.getInstance();
        }
        else
        {
            JOptionPane.showMessageDialog(null,"Failed to commit");
        }


}//GEN-LAST:event_registerActionPerformed

    private void generateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateActionPerformed
        editor=new GenerateID();
        editor.generateID();
    }//GEN-LAST:event_generateActionPerformed

    private void snapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_snapActionPerformed

        id=this.rid.getText();
        camera=new PhotoCamera();
        camera.run(id);
        photo.repaint();
}//GEN-LAST:event_snapActionPerformed

    private void dormitoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dormitoryActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_dormitoryActionPerformed

    private void edateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_edateActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_edateActionPerformed

    private void groupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_groupActionPerformed
        switcher=new GeneralSwitch();
        switcher.componentSwitch();
}//GEN-LAST:event_groupActionPerformed

    private void phoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_phoneActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_phoneActionPerformed

    private void addressActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addressActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_addressActionPerformed

    private void nameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nameActionPerformed

}//GEN-LAST:event_nameActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new RegisterPanel().setVisible(true);


            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField address;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton cancel;
    private javax.swing.JTextField cid;
    private javax.swing.JComboBox college;
    private javax.swing.JPasswordField cpsword;
    private javax.swing.JComboBox degree;
    private javax.swing.JComboBox department;
    private javax.swing.JTextField dormitory;
    private javax.swing.JTextField edate;
    private javax.swing.JComboBox gender;
    private javax.swing.JButton generate;
    private javax.swing.JComboBox group;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JComboBox mcourse;
    private javax.swing.JTextField name;
    private javax.swing.JLabel pathlabel;
    private javax.swing.JPanel perinfo;
    private javax.swing.JTextField phone;
    private javax.swing.JLabel photo;
    private javax.swing.JPanel prialoc;
    private javax.swing.JPanel priinfo;
    private javax.swing.JPasswordField psword;
    private javax.swing.JTextField rdate;
    private javax.swing.JButton register;
    private javax.swing.JTextField rid;
    private javax.swing.JButton snap;
    private javax.swing.JCheckBox stbook;
    private javax.swing.JCheckBox stcourse;
    private javax.swing.JCheckBox stfao;
    private javax.swing.JCheckBox stfbook;
    private javax.swing.JCheckBox stfca;
    private javax.swing.JCheckBox stflib;
    private javax.swing.JCheckBox stfpio;
    private javax.swing.JCheckBox stfsaa;
    private javax.swing.JCheckBox stfsao;
    private javax.swing.JCheckBox tbook;
    private javax.swing.JComboBox title;
    // End of variables declaration//GEN-END:variables
    
}
